package servlet;

import java.io.IOException;
import java.util.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import news.*;

public class LeftServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		Map<Topic, List<News>> map = new HashMap<Topic, List<News>>();
		List<Topic> tlist = TopicDao.dao.findShowTopTopic(true);
		for (Topic c : tlist) {
			List<News> nlist = NewsDao.dao.showOnLeft(c);
			map.put(c, nlist);
		}
		request.setAttribute("map", map);

		request.getRequestDispatcher("WEB-INF/jsp/left.jsp").include(request,
				response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doGet(request, response);
	}

}
